import {ref,onMounted,onUnmounted} from 'vue';

export default function useGetMousePosition() {
    const x = ref(0);
    const y = ref(0);

    const updatePosition = (e:MouseEvent) =>{
        x.value = e.pageX;
        y.value = e.pageY;
    };

    onMounted(()=>{
        document.addEventListener('click',updatePosition);
    });
    onUnmounted(()=>{
        document.removeEventListener('click',updatePosition);
    });
    return {
        x,y
    };
};